

package com.hazelcast.jet.pipeline;

import com.hazelcast.internal.serialization.SerializableByConvention;

import java.io.Serial;

/**
 * Represents the definition of a session window.
 *
 * @since Jet 3.0
 */
@SerializableByConvention
public class SessionWindowDefinition extends WindowDefinition {

    @Serial
    private static final long serialVersionUID = 1L;

    private final long sessionTimeout;

    SessionWindowDefinition(long sessionTimeout) {
        this.sessionTimeout = sessionTimeout;
    }

    @Override
    public SessionWindowDefinition setEarlyResultsPeriod(long earlyResultPeriodMs) {
        return (SessionWindowDefinition) super.setEarlyResultsPeriod(earlyResultPeriodMs);
    }

    /**
     * Returns the session timeout, which is the largest difference in the
     * timestamps of any two consecutive events in the session window.
     */
    public long sessionTimeout() {
        return sessionTimeout;
    }
}
